<?php declare(strict_types=1);


namespace PinWuYun\domain\helper;

/**
 * Created: by zhiJie
 * Date: 2021/6/23
 */
class GoodsPriceHelper
{
    private $minPrice = 0;
    private $maxPrice = 0;

    // 如果有比最大大的，替换  允许接受多个参数
    public function checkMaxPrice(...$price)
    {
        foreach ($price as $value) {
            if($value > $this->getMaxPrice()) {
                $this->setMaxPrice($value);
            }
        }
    }

    // 如果有比最小小的，替换  允许接受多个参数
    public function checkMinPrice(...$price)
    {
        foreach ($price as $value) {
            if($value < $this->getMaxPrice()) {
                $this->setMinPrice($value);
            }
        }


    }



//----------- get or set prop function
    /**
     * @return float
     */
    public function getMinPrice(): float
    {
        return $this->minPrice;
    }

    /**
     * @param float $minPrice
     * @return GoodsPriceHelper
     */
    public function setMinPrice(float $minPrice): GoodsPriceHelper
    {
        $this->minPrice = $minPrice;
        return $this;
    }

    /**
     * @return float
     */
    public function getMaxPrice(): float
    {
        return $this->maxPrice;
    }

    /**
     * @param float $maxPrice
     * @return GoodsPriceHelper
     */
    public function setMaxPrice(float $maxPrice): GoodsPriceHelper
    {
        $this->maxPrice = $maxPrice;
        return $this;
    }



}